import { useEffect, useState } from "react"
import { getChannelApi, type ChannelItem } from "@/api"

const useTabs = () => {
  const [channels, setChannels] = useState<ChannelItem[]>([])

  const getChannels = async () => {
    try {
      const res = await getChannelApi()
      setChannels(res.data.data.channels)
    } catch (error) {
      console.log('fetch channel error', error)
    }
  }
  useEffect(() => {
    getChannels()
  }, [])

  return {
    channels
  }
}

export { useTabs }